//
//  JDelegateController.m
//  HeadIndustry
//
//  Created by jun on 2017/9/21.
//  Copyright © 2017年 jun. All rights reserved.
//

#import "JDelegateController.h"

@interface JDelegateController ()

@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) YYLabel *titleStrLabel;
@property (nonatomic, strong) UILabel *textStrLabel;


@end

@implementation JDelegateController

- (void)viewDidLoad {
    [super viewDidLoad];
    [super InitUI];
    self.titleLabel.text = @"条款协议";
    self.leftButton.hidden = NO;
    [self.leftButton setImage:[UIImage imageNamed:backBtnImg] forState:UIControlStateNormal];
    self.leftButton.frame = CGRectMake(8, self.leftButton.frame.origin.y, 30, 30);
    [self setConfigBgView];
    
    [self loadGetTextRequest];
}

- (void)setConfigBgView
{
    self.automaticallyAdjustsScrollViewInsets = NO;
    _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, kWindowH, self.contentView.height)];
    _scrollView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:_scrollView];
    
    YYLabel *title = [YYLabel new];
    title.top = 0;
    title.left = 0;
    title.size = CGSizeMake(kWindowW, 60);
    title.font = kFONT_TITLE(24);
    title.textColor = kRGBColor(119, 119, 119);
    title.textAlignment = NSTextAlignmentCenter;
    [_scrollView addSubview:title];
//    title.text = @"网聊协议";
    _titleStrLabel = title;
    
    UILabel *textlabel = [[UILabel alloc]initWithFrame:CGRectMake(10, title.bottom, kWindowW - 20, 200)];
    textlabel.font = kFONT_TITLE(16);
    textlabel.numberOfLines = 0;
    textlabel.textColor = kRGBColor(119, 119, 119);
    [_scrollView addSubview:textlabel];
    _textStrLabel = textlabel;
}


- (void)loadGetTextRequest {
    NSString *url = @"Cirle/GetSocialHubNotes";
    
    [JNetManager GetGetSocialHubNotesRequedtUrl:url
                                        success:^(id response) {
                                            if (response) {
//                                                Id = 583;
//                                                Name = "\U7f51\U804a\U534f\U8bae";
//                                                StoreId = 0;
//                                                Value = "<p>1\U3001\U4fd
                                                NSDictionary *dic = response;
                                                _titleStrLabel.text = dic[@"Name"];
                                                NSString *textStr = dic[@"Value"];
                                                NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[textStr dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
                                                
                                                _textStrLabel.attributedText = attrStr;
                                                CGSize sizeLable = [_textStrLabel sizeThatFits:CGSizeMake(kWindowW - 20, 1000)];
                                              
                                                _textStrLabel.frame = CGRectMake(10, _titleStrLabel.bottom, kWindowW - 20, sizeLable.height + 10);
                                                
                                                _scrollView.contentSize = CGSizeMake(kWindowW, _textStrLabel.bottom);
                                                
                                                
                                            }
                                        } failure:^(NSString *err) {
                                            [SVProgressHUD showErrorWithStatus:err];
                                        }];
}

- (void)leftButtonClick:(UIButton *)leftButton
{
    [super leftButtonClick:leftButton];
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
